﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace AlphaWindow
{
	public enum TBool
	{
		False = 0,
		True
	};

	[StructLayout(LayoutKind.Sequential)]
	public struct TPoint
	{
		public Int32 X;
		public Int32 Y;

		public TPoint(Int32 X, Int32 Y)
		{
			this.X = X; this.Y = Y;
		}
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct TSize
	{
		public Int32 Width;
		public Int32 Height;

		public TSize(Int32 Width, Int32 Height)
		{
			this.Width = Width; this.Height = Height;
		}
	}

	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public struct BLENDFUNCTION
	{
		public byte BlendOp;
		public byte BlendFlags;
		public byte SourceConstantAlpha;
		public byte AlphaFormat;
	}

	public static class Win32Helper
	{
		#region Constants
		public const Int32 ULW_COLORKEY = 0x00000001;
		public const Int32 ULW_ALPHA = 0x00000002;
		public const Int32 ULW_OPAQUE = 0x00000004;

		public const byte AC_SRC_OVER = 0x00;
		public const byte AC_SRC_ALPHA = 0x01;

		public const uint WM_SYSCOMMAND = 0x0112;
		public const uint DOMOVE = 0xF012;
		public const uint DOSIZE1 = 0xF001;
		public const uint DOSIZE2 = 0xF002;
		public const uint DOSIZE3 = 0xF003;
		public const uint DOSIZE4 = 0xF004;
		public const uint DOSIZE5 = 0xF005;
		public const uint DOSIZE6 = 0xF006;
		public const uint DOSIZE7 = 0xF007;
		public const uint DOSIZE8 = 0xF008;

		public const uint SRCCOPY = 0x00CC0020;
		#endregion

		#region DllImports
		[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern IntPtr GetDC(IntPtr hWnd);

		[DllImport("user32.dll", ExactSpelling = true)]
		public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

		[DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern IntPtr CreateCompatibleDC(IntPtr hDC);

		[DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern TBool DeleteDC(IntPtr hdc);

		[DllImport("gdi32.dll", ExactSpelling = true)]
		public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);

		[DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern TBool DeleteObject(IntPtr hObject);

		[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern TBool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref TPoint pptDst, ref TSize psize, IntPtr hdcSrc, ref TPoint pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);

		[DllImport("user32", CharSet = CharSet.Auto)]
		public extern static bool PostMessage(IntPtr hWnd, uint Msg, uint WParam, uint LParam);

		[DllImport("user32", CharSet = CharSet.Auto)]
		public extern static bool ReleaseCapture();

		[DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern TBool BitBlt(IntPtr hDest, int xDest, int yDest, int nWidth, int nHeight, IntPtr hSrc, int xSrc, int ySrc, uint dwrOp);

		[DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
		public static extern TBool StretchBlt(IntPtr hDest, int DestX, int DestY, int DestW, int DestH, IntPtr hSrc, int SrcX, int SrcY, int SrcW, int SrcH, uint dwrOp);
		#endregion

	}


}
